﻿<UserControl x:Class="Module1.Views.MasterView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:prism="http://www.codeplex.com/prism"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactions"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <UserControl.Resources>
        <Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
        </Style>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FF7B97D4" />
                <GradientStop Color="#FF244C8D" Offset="1" />
            </LinearGradientBrush>
        </Grid.Background>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Text="Master View (Module 1)" TextWrapping="Wrap" FontSize="16" Foreground="#FF2F3806" Margin="8,8,8,2"/>

        <TextBlock Grid.Row="1" TextWrapping="Wrap" FontSize="10" Foreground="#FF2F3806" Margin="8,2,8,8">
            <Run Text="This view demonstrates Prism's support for commands, collection views, inter-module communication and navigation." />
            <Run Text="Select an item to update the view in the region below." />
            <Run Text="Click the navigation buttons to create or synchronize views in the main region to the right." />
        </TextBlock>
        
        <ListBox x:Name="DataItemListBox" Grid.Row="2" SelectionMode="Single"
                 HorizontalContentAlignment="Stretch" Margin="8,8,8,4"
                 ItemContainerStyle="{StaticResource ListBoxItemStyle}"
                 ItemsSource="{Binding DataItemsCV}">
            <ListBox.BorderBrush>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFAEB9A3"/>
                    <GradientStop Color="#FF83A985" Offset="0.375"/>
                    <GradientStop Color="#FF719778" Offset="0.379"/>
                    <GradientStop Color="#FF61846E" Offset="1"/>
                </LinearGradientBrush>
            </ListBox.BorderBrush>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border CornerRadius="6">
                    	<Border.Background>
                    		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    			<GradientStop Color="#BF8D97A1" Offset="0"/>
                    			<GradientStop Color="#BDCFD9E0" Offset="1"/>
                    		</LinearGradientBrush>
                    	</Border.Background>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*" MinWidth="20"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                			<Image Grid.Column="0" Height="48" Width="48" Margin="6,6,6,4" HorizontalAlignment="Center" Source="/Module1;component/Images/ItemIcon.png" />
                            <StackPanel Grid.Column="1" Orientation="Vertical" Margin="4,6" HorizontalAlignment="Left">
                                <TextBlock Text="{Binding Name}" />
                                <TextBlock Text="{Binding Description}" />
                                <TextBlock Text="{Binding Id}" />
                            </StackPanel>
                            <StackPanel Grid.Column="2" Orientation="Vertical" Margin="4,6,6,6" HorizontalAlignment="Right">
                                <!--Bind to commands on the view model from within each list box item-->
                                <Button prism:Click.Command="{Binding DataContext.NavigateToViewCommand, ElementName=DataItemListBox}"
                					    prism:Click.CommandParameter="{Binding Id}" Margin="2"
                                        ToolTipService.ToolTip="Click to navigate to the Edit View for this item.">
                                    <Image Height="20" Width="20" Source="/Module1;component/Images/NavigateToView.png" />
                                </Button>
                                <Button prism:Click.Command="{Binding DataContext.SyncViewCommand, ElementName=DataItemListBox}"
                					    prism:Click.CommandParameter="{Binding Id}" Margin="2"
                                        ToolTipService.ToolTip="Click to synchronize the Details View for this item.">
                                    <Image Height="20" Width="20" HorizontalAlignment="Center" Source="/Module1;component/Images/SyncView.png" />
                                </Button>
                            </StackPanel>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>

</UserControl>
